package org.swxjava.assembler.avm1;

import org.swxjava.assembler.Constants;
import org.swxjava.assembler.ObjectCompiler;
import org.swxjava.util.Log;
import org.swxjava.util.LogFactory;

public class AsBoolean implements ObjectCompiler {

	/** Logger */
	private static final Log LOG = LogFactory.getLog(AsBoolean.class);

	public static final AsBoolean TRUE = new AsBoolean(Boolean.TRUE);

	public static final AsBoolean FALSE = new AsBoolean(Boolean.FALSE);

	/** value */
	private Boolean value = false;

	public AsBoolean(Boolean value) {
		this.value = value;
	}

	public int getByteSize() {
		return toString().length() / 2;
	}

	public byte[] toBytecode() {
		// TODO Auto-generated method stub
		return null;
	}

	public String toString() {
		return booleanToBytecode(value);
	}

	public static String booleanToBytecode(boolean bool) {
		String boolBytecode = Constants.DATA_TYPE_BOOLEAN
				+ ((bool) ? "01" : "00");
		return boolBytecode;
	}
}
